home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Z80 emulator / 68K version / cmd_IX⁄IY_CB.c < prev    next >
Encoding:
Text File  |  1995-11-01  |  2.8 KB  |  112 lines  |  [TEXT/CWIE]

  1.  
  2.  
  3. // -----    ix/iy + CB Command Dispatcher -----------------------------------------------
  4. //    entry condition: a1 points to the required index register
  5.  
  6. //    Handling of illegals:        (G.Lunter: Z80.DOC)
  7. //    index n is read immediately after CB for every IXCB/IYCB instruction, even if not used
  8. //    { DD CB nn XX }  works like  { DD CB nn (XX&F8+6) }  and copies result to register (XX&07)
  9.  
  10.  
  11. XYCB:    
  12.  
  13. // -----    don't increment r register
  14. //    double shifted opcodes increment r by 2
  15. //    and this is done in the main instruction dispatcher (( +1 ))
  16. //    and in the ix/iy command dispatcher (( +1 again ))
  17. #if EXACT_R
  18. #endif
  19.  
  20.  
  21. // -----    update T cycle counter
  22. //    all shift, bit set and bit clear instructions take 23 T cycles
  23. //    all bit test instructions take 20 T cycles
  24.     more8
  25.     more4                // 4+8+4 = 16 T cycles
  26.     
  27.  
  28. // -----    calculate target address ------------------------------------------------
  29.     move.b    (ip)+,core            // offset  n
  30.     ext.w    core    
  31.     add.w    ir,core            // target address  ir+n
  32.  
  33.  
  34. // -----    get instruction --------------------------------------------------------
  35.     move.b    (ip)+,db            // instruction
  36.  
  37.  
  38. // -----    debugger related testings ----------------------------------------------
  39. #if CMD_PROFILE || cmd_firstuse
  40.     movea.l    cnt_xycb,a0
  41. //    addq.l    #1,(a0,db.l*4)
  42.     lsl    #2,db
  43.     addq.l    #1,(a0,db.l)
  44.     lsr    #2,db
  45. #if cmd_firstuse
  46.     bne.s    cmdicb2  }; Do_1st_Instr ( ip-4 ); asm {  cmdicb2:
  47. #endif
  48. #endif
  49.  
  50.  
  51. // -----    load target address in a0 register ------------------------------    
  52.     move.l    core,a0            // a0 -> target of operation
  53.  
  54.  
  55. // -----    check for illegal instruction ------------------------------------
  56. #if exact_xy_bit
  57.     subq.b    #6,db        // assume: (hl)
  58.     moveq    #0x07,d0
  59.     and.b    db,d0
  60.     bne.s    cbxill        // illegal register => special action
  61. #endif
  62.     
  63.  
  64. // -----    dispatch ------------------------------------------------------
  65. cbxdis:    lsr.b    #3,db
  66.     dc.w    0x43FB, 0x4A06        // lea    *+$08(D4.l*2),A1
  67.     adda.w    (a1),a1
  68.     jmp    (a1)
  69.  
  70. // if exact_xy_bit, all these entries must preserve A0
  71. // note: handling after write_to_rom should be corrected
  72. cbxtab:    dc.w    rlcx,     rrcx,     rlx,    rrx,    slax,    srax,    sllx,    srlx
  73.     dc.w    bit0x,    bit1x,    bit2x,    bit3x,    bit4x,    bit5x,    bit6x,    bit7x
  74.     dc.w    res0x,    res1x,    res2x,    res3x,    res4x,    res5x,    res6x,    res7x
  75.     dc.w    set0x,    set1x,    set2x,    set3x,    set4x,    set5x,    set6x,    set7x
  76.  
  77.  
  78. #if exact_xy_bit
  79. // illegal register number
  80. cbxill:    addq.b    #6,db
  81.     move.l    loop,-(a7)
  82.     lea    cbxx,loop
  83.     bra.s    cbxdis        // back to normal dispatcher
  84.  
  85. // after normal instruction execution, copy result (core.l) to register
  86. cbxx:    move.l    (a7)+,loop
  87.     move.b    (a0),db        // get result
  88.     do_info_illegals4
  89.     moveq    #0x07,d0
  90.     and.b    -1(ip),d0        // get register
  91.     add.l    d0,d0
  92.     lea    cbx_tab(d0.l),a1
  93.     adda.w    (a1),a1
  94.     jmp    (a1)
  95.  
  96. cbx_tab:    dc.w    cbxb, cbxc, cbxd, cbxe, cbxh, cbxl, nxtcmnd, cbxa
  97. cbxb:    move.b    db,RB;    m_next
  98. cbxc:    move.b    db,RC;    m_next
  99. cbxd:    move.b    db,RD;    m_next
  100. cbxe:    move.b    db,RE;    m_next
  101. cbxh:    move.b    db,RH;    m_next
  102. cbxl:    move.b    db,RL;    m_next
  103. cbxa:    move.b    db,a;    m_next
  104. #endif
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.